package com.topc.participant.model.vo;

import cn.hutool.core.util.ObjectUtil;
import com.topc.participant.model.po.MenuInfo;
import lombok.Data;
import lombok.experimental.Accessors;

import java.util.ArrayList;
import java.util.List;

@Data
@Accessors(chain = true)
public class MenuTreeShowVo {

    private String title;

    private Long key;

    private Boolean disabled;

    private List<MenuTreeShowVo> children;

    public MenuTreeShowVo() {
        disabled = false;
    }

    public void addChildren(MenuTreeShowVo menuTreeShowVo) {
        if (ObjectUtil.isEmpty(children))
            children = new ArrayList<>();
        children.add(menuTreeShowVo);
    }

    public MenuTreeShowVo(MenuInfo menuInfo) {
        this.title = menuInfo.getMenuName();
        this.disabled = (menuInfo.getIsParent() != 0);
        this.key = menuInfo.getId();
    }
}
